package xmarti.vacaxm.beans.maintenance;

import java.util.Calendar;
import java.util.Date;
import xmarti.vacaxm.beans.connect.Destination;
import xmarti.vacaxm.beans.connect.Origin;
public abstract class Animal extends AnimalCode implements java.io.Serializable {
    private Date birthDate;	
    private Date highDate;
    private Date lowDate;
    private Bull father;
    private Cow mother; 
    private Origin origin;
    private Destination destination; 
    private Breed breed;
    private boolean active;
    public Animal () {
            super(); 
            active=true;
    }
    
    public Animal(Country country, String controlCode, Area areaCode, String animalCode1, String animalCode2) {
        super(country, controlCode, areaCode, animalCode1, animalCode2);
        active=true; 
    }
    
    
    
    /**
     * @return the birthDate
     */
    public Date getBirthDate() {
            return birthDate;
    }
    /**
     * @param birthDate the birthDate to set
     */
    public void setBirthDate(Date birthDate) {
            this.birthDate = birthDate;
    }
    /**
     * @return the highData
     */
    public Date getHighDate() {
            return highDate;
    }
    /**
     * @param highData the highData to set
     */
    public void setHighDate(Date highData) {
            this.highDate = highData;
    }
    /**
     * @return the lowData
     */
    public Date getLowDate() {
            return lowDate;
    }
    /**
     * @param lowData the lowData to set
     */
    public void setLowDate(Date lowData) {
            this.lowDate = lowData;
    }

    

    /**
     * @return the father
     */
    public Bull getFather() {
            return father;
    }
    /**
     * @param father the father to set
     */
    public void setFather(Bull father) {
            this.father = father;
    }
    /**
     * @return the mother
     */
    public Cow getMother() {
            return mother;
    }
    /**
     * @param mother the mother to set
     */
    public void setMother(Cow mother) {
            this.mother = mother;
    }
    /**
     * @return the origin
     */
    public Origin getOrigin() {
            return origin;
    }
    /**
     * @param origin the origin to set
     */
    public void setOrigin(Origin origin) {
            this.origin = origin;
    }
    /**
     * @return the destination
     */
    public Destination getDestination() {
            return destination;
    }
    /**
     * @param destination the destination to set
     */
    public void setDestination(Destination destination) {
            this.destination = destination;
	}

    public boolean isActive() {
        return active;
    }

    public void setActive(boolean active) {
        this.active = active;
    }

    public Breed getBreed() {
        return breed;
    }

    public void setBreed(Breed breed) {
        this.breed = breed;
    }
    
    public long getAge(){
        if (birthDate==null) return 0; 
        final long MILLSECS_PER_DAY = 24 * 60 * 60 * 1000; //Milisegundos al día 
        Date today = new Date(); //Fecha de hoy 
        Calendar calendarStart = Calendar.getInstance();
        Calendar calendarEnd= Calendar.getInstance(); 
        calendarStart.setTime(birthDate);
        calendarEnd.setTime(today);        
        return ((calendarEnd.getTimeInMillis()-calendarStart.getTimeInMillis())/MILLSECS_PER_DAY);
    }
    public abstract String getName();
    public abstract String getCodeAnimalToString();
    public abstract void setName(String name);
}
